<html>
<head><meta charset="utf-8"><title>stack overflows · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html">stack overflows</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="175929523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175929523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175929523">(Sep 17 2019 at 17:34)</a>:</h4>
<p>Something changed between yesterday and today. I am now getting a lot of exciting</p>
<blockquote>
<p>thread '&lt;unknown&gt;' has overflowed its stack<br>
[Error - 1:33:16 PM] Connection to server got closed. Server will not be restarted.<br>
[Error - 1:33:16 PM] Request textDocument/codeAction failed.</p>
</blockquote>



<a name="175929930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175929930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175929930">(Sep 17 2019 at 17:38)</a>:</h4>
<p>Yeah, noticed this as well! Rolled back the latest commit from master just moments ago</p>



<a name="175930044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175930044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175930044">(Sep 17 2019 at 17:40)</a>:</h4>
<p>Did you do a force push? Looks like I have to force the checkout</p>



<a name="175930217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175930217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175930217">(Sep 17 2019 at 17:41)</a>:</h4>
<p>I mean a reset</p>



<a name="175930446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175930446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175930446">(Sep 17 2019 at 17:43)</a>:</h4>
<p>Yeah, I've force pushed</p>



<a name="175930700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175930700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175930700">(Sep 17 2019 at 17:46)</a>:</h4>
<p>That seems to have fixed it</p>



<a name="175931033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175931033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175931033">(Sep 17 2019 at 17:49)</a>:</h4>
<p>hm, I'll check it</p>



<a name="175932780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175932780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175932780">(Sep 17 2019 at 18:06)</a>:</h4>
<p>oh... </p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">Trait</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">T</span>::<span class="n">Item</span>: <span class="nc">Trait2</span><span class="w"></span>
</pre></div>


<p>we want to lower the types in the where clauses, so we need to select the trait where <code>Item</code> comes from, so we look into the where clauses, so we need to lower the types in the where clauses...</p>



<a name="175935084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/175935084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#175935084">(Sep 17 2019 at 18:31)</a>:</h4>
<p>ah... should have read rustc <span aria-label="big smile" class="emoji emoji-1f604" role="img" title="big smile">:big_smile:</span> <a href="https://github.com/rust-lang/rust/blob/9150f844e2624eb013ec78ca08c1d416e6644026/src/librustc_typeck/astconv.rs#L46" target="_blank" title="https://github.com/rust-lang/rust/blob/9150f844e2624eb013ec78ca08c1d416e6644026/src/librustc_typeck/astconv.rs#L46">https://github.com/rust-lang/rust/blob/9150f844e2624eb013ec78ca08c1d416e6644026/src/librustc_typeck/astconv.rs#L46</a></p>



<a name="230781433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230781433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230781433">(Mar 17 2021 at 22:40)</a>:</h4>
<p>Since today I've started seeing some random stack overflows every now and then when editing files. Have yet to see a pattern though <span aria-label="confused" class="emoji emoji-1f615" role="img" title="confused">:confused:</span><br>
I also seem to get a few HIR display panics like <a href="https://github.com/rust-analyzer/rust-analyzer/issues/8077">https://github.com/rust-analyzer/rust-analyzer/issues/8077</a> since yesterday I think</p>



<a name="230831992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230831992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230831992">(Mar 18 2021 at 09:09)</a>:</h4>
<p><a href="https://crates.io/crates/backtrace-on-stack-overflow">https://crates.io/crates/backtrace-on-stack-overflow</a> might be useful</p>



<a name="230832123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230832123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230832123">(Mar 18 2021 at 09:10)</a>:</h4>
<p>I noticed some clippy warnings about some recursive <code>Display</code> impls, but they're probably FPs</p>



<a name="230832145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230832145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230832145">(Mar 18 2021 at 09:10)</a>:</h4>
<p>Also, that was before yesterday</p>



<a name="230836874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230836874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230836874">(Mar 18 2021 at 09:53)</a>:</h4>
<p>Hm, I am seeing a panic in attrs handing, not a stack overflow: </p>
<div class="codehilite"><pre><span></span><code>thread &#39;&lt;unnamed&gt;&#39; panicked at &#39;cannot find `Attr` at index 0&#39;, crates/hir_def/src/attr.rs:395:32
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:435:5
   2: hir_def::attr::AttrSourceMap::source_of::{{closure}}
   3: hir_def::attr::AttrSourceMap::source_of
   4: ide::syntax_highlighting::inject::doc_comment
   5: ide::syntax_highlighting::highlight
   6: std::panicking::try
   7: ide::Analysis::highlight
   8: rust_analyzer::handlers::handle_semantic_tokens_full
</code></pre></div>



<a name="230837058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230837058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230837058">(Mar 18 2021 at 09:55)</a>:</h4>
<p>That one looks like its on me <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="230838379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230838379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230838379">(Mar 18 2021 at 10:07)</a>:</h4>
<p>Though that panic is weird, I'm not sure why that's happening <span aria-label="confused" class="emoji emoji-1f615" role="img" title="confused">:confused:</span></p>



<a name="230839258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230839258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230839258">(Mar 18 2021 at 10:14)</a>:</h4>
<p>Okay I can reproduce it reliably i think</p>
<div class="codehilite"><pre><span></span><code>//! A simplified AST that only contains items.

mod lower;
</code></pre></div>
<p>This seems to panic :/</p>



<a name="230843945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230843945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230843945">(Mar 18 2021 at 10:56)</a>:</h4>
<p>Okay the problem is that the Attribute source mapping doesnt work so easily. Attributes of outline modules can have two different owner nodes. I guess wrapping <code>Attr</code> in an <code>InFile</code> would help here to track where they came from? Would that be an okay approach to fix this?</p>
<p>Actually no this wouldn't help</p>



<a name="230850489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230850489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230850489">(Mar 18 2021 at 11:58)</a>:</h4>
<p>On another Note, did completions get slower? I feel like VSCode is showing me only basic text completions quite frequently now</p>



<a name="230857303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230857303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230857303">(Mar 18 2021 at 12:55)</a>:</h4>
<p>it might have, we enabled auto-imports in more cases. Really, we should "somehow" push auto-imports to be instant. I don't know how, but, intuitevely, auto-import suggestion don't change much, so the lookup should be fashayt</p>



<a name="230881512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230881512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230881512">(Mar 18 2021 at 15:18)</a>:</h4>
<p>Okay I am actually able to reproduce the stack overflow, given</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">group_label</span><span class="p">(</span><span class="n">candidate</span>: <span class="kp">&amp;</span><span class="nc">ImportCandidate</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">GroupLabel</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">candidate</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">ImportCandidate</span>::<span class="n">Path</span><span class="p">(</span><span class="n">it</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="o">&amp;</span><span class="n">it</span><span class="p">.</span><span class="n">name</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">ImportCandidate</span>::<span class="n">TraitAssocItem</span><span class="p">(</span><span class="n">it</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">ImportCandidate</span>::<span class="n">TraitMethod</span><span class="p">(</span><span class="n">it</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="o">&amp;</span><span class="n">it</span><span class="p">.</span><span class="n">assoc_item_name</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"> </span><span class="c1">// &lt;------</span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">.</span><span class="n">text</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">GroupLabel</span><span class="p">(</span><span class="fm">format!</span><span class="p">(</span><span class="s">"Qualify {}"</span><span class="p">,</span><span class="w"> </span><span class="n">name</span><span class="p">))</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>in <code>handlers/qualify_path.rs</code> as an example<br>
When deleting the annotated <code>}</code> the server completely dies on a stack overflow</p>



<a name="230881531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230881531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230881531">(Mar 18 2021 at 15:18)</a>:</h4>
<p>This seems to happen with any <code>match</code></p>



<a name="230881905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230881905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230881905">(Mar 18 2021 at 15:20)</a>:</h4>
<p>Oh no if one doesn't fix the syntax error it just keeps crashing on restart <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="230882509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230882509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230882509">(Mar 18 2021 at 15:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133169">matklad</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/stack.20overflows/near/230831992">said</a>:</p>
<blockquote>
<p><a href="https://crates.io/crates/backtrace-on-stack-overflow">https://crates.io/crates/backtrace-on-stack-overflow</a> might be useful</p>
</blockquote>
<p>Guess I'll try to debug this later with the crate you mentioned</p>



<a name="230887629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230887629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230887629">(Mar 18 2021 at 15:50)</a>:</h4>
<p>Okay I don't think I need the backtrace(+ I dont have a linux machine atm so I cant really use it), but if Im guessing this right the problem is expression-statement error recovery.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">{;</span><span class="w"></span>
</code></pre></div>
<p>also causes crashes. And it only crashes when a lot of source follows the syntax error which makes me believe it is error recovery causing problems?</p>



<a name="230888895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230888895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230888895">(Mar 18 2021 at 15:57)</a>:</h4>
<p>Syntax error recovery? Yeah, that might be it!</p>
<p>I think the best way to debug this is to paste the offending code into <code>parser_smoke_test</code> <a href="https://github.com/rust-analyzer/rust-analyzer/blob/d704750ba982153d92ccff90cf236121641b9da3/crates/syntax/src/tests.rs#L32-L43">https://github.com/rust-analyzer/rust-analyzer/blob/d704750ba982153d92ccff90cf236121641b9da3/crates/syntax/src/tests.rs#L32-L43</a></p>



<a name="230892461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230892461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230892461">(Mar 18 2021 at 16:09)</a>:</h4>
<p>Hm, doesn't stack overflow there :/ guess its not error recovery then, thought then I'm keen to find out what it is instead</p>



<a name="230913593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230913593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230913593">(Mar 18 2021 at 18:14)</a>:</h4>
<p>So apparently <code>Declvalidator::validate_item</code> is recursing endlessly</p>



<a name="230917890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230917890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230917890">(Mar 18 2021 at 18:44)</a>:</h4>
<p>So Im pretty sure the reason for why this stack overflow is happening now is thanks to local nameres <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="230918000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918000">(Mar 18 2021 at 18:45)</a>:</h4>
<p>Though I wonder why this is happening when there is such a syntax error, from the looks of it the syntax tree gets very much malformed and I guess the HIR gets incorrectly constructred therefor</p>



<a name="230918002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918002">(Mar 18 2021 at 18:45)</a>:</h4>
<p>oof</p>



<a name="230918015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918015">(Mar 18 2021 at 18:45)</a>:</h4>
<p>any way to reproduce this?</p>



<a name="230918030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918030">(Mar 18 2021 at 18:45)</a>:</h4>
<p>very easily</p>



<a name="230918115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918115">(Mar 18 2021 at 18:46)</a>:</h4>
<p>Putting <code>if let x = x{;</code> here <a href="https://github.com/rust-analyzer/rust-analyzer/blob/d0805c6444e06e082465cd1a064c83c0f90faf71/crates/ide_assists/src/handlers/qualify_path.rs#L45">https://github.com/rust-analyzer/rust-analyzer/blob/d0805c6444e06e082465cd1a064c83c0f90faf71/crates/ide_assists/src/handlers/qualify_path.rs#L45</a></p>



<a name="230918127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918127">(Mar 18 2021 at 18:46)</a>:</h4>
<p>crashes the server</p>



<a name="230918318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918318">(Mar 18 2021 at 18:47)</a>:</h4>
<p>and commenting out <code>validate_item</code> prevents the crash</p>



<a name="230918445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918445">(Mar 18 2021 at 18:48)</a>:</h4>
<p>If I see this right the syntax tree is completely incorrect after this, basically <strong><em>everything</em></strong> that follows the incorrect <code>if let</code> there seems to become the <code>if let</code> nodes child node</p>



<a name="230918505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918505">(Mar 18 2021 at 18:49)</a>:</h4>
<p>So I imagine the problem is the HIR getting cycles somehow due to this?</p>



<a name="230918587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918587">(Mar 18 2021 at 18:49)</a>:</h4>
<p>could be!</p>



<a name="230918648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230918648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230918648">(Mar 18 2021 at 18:49)</a>:</h4>
<p>I've seen hangs and crashes related to local nameres when refactoring ItemTree</p>



<a name="230919952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230919952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230919952">(Mar 18 2021 at 18:59)</a>:</h4>
<p>Yep so everything after the syntax error becomes a local item to the first function syntax tree wise it turns out <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="230919963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230919963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230919963">(Mar 18 2021 at 18:59)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">qualify_path</span><span class="p">()</span><span class="w">  </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">{;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">mod</span> <span class="nn">tests</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">use</span><span class="w"> </span><span class="k">super</span>::<span class="o">*</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>minimal repro that crashes</p>



<a name="230920177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230920177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230920177">(Mar 18 2021 at 19:00)</a>:</h4>
<p>Corresponding RAST, which shows the incorrect nesting <a href="https://gist.github.com/Veykril/bfb1f9327c906bc61cd88a6ca914accb">https://gist.github.com/Veykril/bfb1f9327c906bc61cd88a6ca914accb</a></p>



<a name="230920807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230920807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230920807">(Mar 18 2021 at 19:04)</a>:</h4>
<p>Okay I can hand this over to you I think Jonas, its not even syntax error related</p>



<a name="230920871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230920871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230920871">(Mar 18 2021 at 19:04)</a>:</h4>
<p>(deleted)</p>



<a name="230920879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230920879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230920879">(Mar 18 2021 at 19:04)</a>:</h4>
<p>(deleted)</p>



<a name="230921263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230921263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230921263">(Mar 18 2021 at 19:07)</a>:</h4>
<p>This crashes <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">qualify</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">mod</span> <span class="nn">foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">use</span><span class="w"> </span><span class="k">super</span>::<span class="o">*</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="230921365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230921365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230921365">(Mar 18 2021 at 19:07)</a>:</h4>
<p>(deleted)</p>



<a name="230921581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230921581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230921581">(Mar 18 2021 at 19:09)</a>:</h4>
<p>It happens when computing diagnostics</p>
<div class="codehilite"><pre><span></span><code>#8848 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8849 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8850 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8851 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8852 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8853 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8854 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8855 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8856 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
#8857 0x00005555560bfc56 in hir_ty::diagnostics::decl_check::DeclValidator::validate_item ()
</code></pre></div>



<a name="230921907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230921907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230921907">(Mar 18 2021 at 19:11)</a>:</h4>
<p>I think I found the issue</p>



<a name="230921946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230921946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230921946">(Mar 18 2021 at 19:11)</a>:</h4>
<p>Ye looks like using importing something from the parent via <code>super</code> inside a module that is inside a function doesn't work too well</p>



<a name="230922053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230922053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230922053">(Mar 18 2021 at 19:12)</a>:</h4>
<p>we were recursively computing diagnostics for all <em>in-scope</em> functions, not just functions that were <em>defined</em> inside a block scope</p>



<a name="230922070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230922070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230922070">(Mar 18 2021 at 19:12)</a>:</h4>
<p>oooh</p>



<a name="230922094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230922094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230922094">(Mar 18 2021 at 19:12)</a>:</h4>
<p>Ye that explains it then <span aria-label="big smile" class="emoji emoji-1f604" role="img" title="big smile">:big_smile:</span></p>



<a name="230922870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230922870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230922870">(Mar 18 2021 at 19:18)</a>:</h4>
<p>Well that was a rather simple fix <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="230922932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/stack%20overflows/near/230922932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/stack.20overflows.html#230922932">(Mar 18 2021 at 19:19)</a>:</h4>
<p>yup, love to see it <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>